---
title: "Installation"
---

## npm

<Tabs>
  <Tab title="npx">
    ```bash
    # PostgreSQL example
    npx @bytebase/dbhub \
      --transport http \
      --port 8080 \
      --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

    # Or use demo mode for testing
    npx @bytebase/dbhub --transport http --port 8080 --demo
    ```
  </Tab>

  <Tab title="Global Installation">
    ```bash
    # Install globally
    npm install -g @bytebase/dbhub

    # Run the server
    dbhub --transport http --port 8080 --dsn "postgres://..."

    # Or use demo mode for testing
    dbhub --transport http --port 8080 --demo
    ```
  </Tab>
</Tabs>

## Docker

<Tabs>
  <Tab title="Docker Run">
    ```bash
    docker run --rm --init \
      --name dbhub \
      --publish 8080:8080 \
      bytebase/dbhub \
      --transport http \
      --port 8080 \
      --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

    # Or use demo mode for testing
    docker run --rm --init \
      --name dbhub \
      --publish 8080:8080 \
      bytebase/dbhub \
      --transport http \
      --port 8080 \
      --demo
    ```

    <Warning>
    When connecting to databases on your host machine from Docker, use `host.docker.internal` instead of `localhost`:

    ```bash
    --dsn "postgres://user:password@host.docker.internal:5432/dbname"
    ```
    </Warning>
  </Tab>

  <Tab title="Docker Compose">
    For development environments using Docker Compose, add DBHub to your `docker-compose.yml`:

    ```yaml docker-compose.yml
    services:
      dbhub:
        image: bytebase/dbhub:latest
        container_name: dbhub
        ports:
          - "8080:8080"
        environment:
          - DBHUB_LOG_LEVEL=info
        command:
          - --transport
          - http
          - --port
          - "8080"
          - --dsn
          - "postgres://user:password@database:5432/dbname"
        depends_on:
          - database

      database:
        image: postgres:15-alpine
        environment:
          POSTGRES_PASSWORD: password
          POSTGRES_DB: dbname
    ```
  </Tab>
</Tabs>

## Verification

After starting DBHub, verify it's running correctly:

```bash
curl http://localhost:8080/healthz
```

You should see "OK" indicating the server is running.

